package com.sunwoda.springbootredis.service.impl;

import com.sunwoda.springbootredis.entity.RequestOrderLine;
import com.sunwoda.springbootredis.dao.RequestOrderLineDao;
import com.sunwoda.springbootredis.service.RequestOrderLineService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (RequestOrderLine)表服务实现类
 *
 * @author makejava
 * @since 2021-09-23 14:22:28
 */
@Service("requestOrderLineService")
public class RequestOrderLineServiceImpl implements RequestOrderLineService {
    @Resource
    private RequestOrderLineDao requestOrderLineDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public RequestOrderLine queryById(Integer id) {
        return this.requestOrderLineDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<RequestOrderLine> queryAllByLimit(int offset, int limit) {
        return this.requestOrderLineDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param requestOrderLine 实例对象
     * @return 实例对象
     */
    @Override
    public RequestOrderLine insert(RequestOrderLine requestOrderLine) {
        this.requestOrderLineDao.insert(requestOrderLine);
        return requestOrderLine;
    }

    /**
     * 修改数据
     *
     * @param requestOrderLine 实例对象
     * @return 实例对象
     */
    @Override
    public RequestOrderLine update(RequestOrderLine requestOrderLine) {
        this.requestOrderLineDao.update(requestOrderLine);
        return this.queryById(requestOrderLine.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.requestOrderLineDao.deleteById(id) > 0;
    }
}
